diff --git a/tests/test_file.py b/tests/test_file.py
index 4dbf4fd9a25e20378294c6f519154c1b25a16c54..f842860c04d504820042fad3a8a4d40f55c934fb 100644
--- a/tests/test_file.py
+++ b/tests/test_file.py
@@ -42,7 +42,7 @@ from caosdb import Info
 from caosdb import administration as admin
 from caosdb import execute_query, get_config, get_connection
 from caosdb.common import models
-from caosdb.exceptions import EntityError
+from caosdb.exceptions import EntityError, TransactionError
 from caosdb.utils.checkFileSystemConsistency import runCheck
 
 
@@ -241,9 +241,10 @@ def test_file6():
                 path="testfiles2/",
                 pickup=path)
 
-            with raises(EntityError) as cm:
+            with raises(TransactionError) as te:
                 folder_.insert()
-            errors = cm.value.entity.get_errors()
+            cm = te.value.get_errors()[0]
+            errors = cm.entity.get_errors()
             assert errors[0].description == 'This target path does already exist.'
     finally:
         try:
@@ -300,7 +301,9 @@ def test_file7():
                 path="testfiles2/",
                 pickup="path")
 
-            assert_raises(EntityError, folder_.insert)
+            with raises(TransactionError) as te:
+                folder_.insert()
+            assert te.value.has_error(EntityError)
     finally:
         try:
             folder_.delete()