diff --git a/tests/test_file.py b/tests/test_file.py
index d1bc6bc0c9993ee23ab83b853692c205a21815b3..344145075bada9e6a1f02ed4e4c87af0ed7c3a62 100644
--- a/tests/test_file.py
+++ b/tests/test_file.py
@@ -37,11 +37,12 @@ from nose.tools import (assert_equal, assert_false,  # @UnresolvedImport
                         assert_is_not_none, assert_raises, assert_true,
                         nottest, with_setup)
 
-from caosdb import execute_query, get_config, get_connection, Info
+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.utils.checkFileSystemConsistency import runCheck
-from caosdb import administration as admin
 
 
 def setup_module():
@@ -49,9 +50,8 @@ def setup_module():
 
 
 def setup():
-    upload_file = open("test.dat", "w")
-    upload_file.write("hello world\n")
-    upload_file.close()
+    with open("test.dat", "w") as upload_file:
+        upload_file.write("hello world\n")
     os.makedirs("testfolder/subfolder")
     with open("testfolder/test1.dat", "w") as upload_file:
         upload_file.write("hello world\n")
@@ -354,6 +354,9 @@ def test_consistency_file_was_modified():
         assert_equal(c.messages["Info", 0][0], "File system is consistent.")
 
         # run consistency check with modified warning)
+        # TODO fix
+        # This smells badly. The argument is meant to transport the location
+        # that is checked. Understanding of the code is difficult.
         c = runCheck(None, "-c FILE_WAS_MODIFIED")
         assert_is_not_none(c.messages["Error", 0])
         assert_equal(
@@ -396,9 +399,8 @@ def test_consistency_file_was_modified():
 @with_setup(setup, teardown)
 def test_consistency_file_does_not_exist():
     try:
-        upload_file = open("test.dat", "w")
-        upload_file.write("hello world\n")
-        upload_file.close()
+        with open("test.dat", "w") as upload_file:
+            upload_file.write("hello world\n")
         file_ = models.File(name="TestConsistency1",
                             description="Testfile Desc",
                             path="debug/test_file_storage_consistency",
@@ -413,6 +415,9 @@ def test_consistency_file_does_not_exist():
         assert_equal(c.messages["Info", 0][0],
                      "File system below debug/ is consistent.")
 
+        # TODO fix
+        # This smells badly. The argument is meant to transport the location
+        # that is checked. Understanding of the code is difficult.
         c = runCheck(None, "-c FILE_DOES_NOT_EXIST")
         assert_is_not_none(c.messages["Error", 0])
         assert_equal(
@@ -453,6 +458,9 @@ def test_consistency_unknown_file():
     assert_is_not_none(c.messages["Info", 0])
     assert_equal(c.messages["Info", 0][0], "File system is consistent.")
 
+    # TODO fix
+    # This smells badly. The argument is meant to transport the location
+    # that is checked. Understanding of the code is difficult.
     c = runCheck(None, "-c UNKNOWN_FILE")
     assert_is_not_none(c.messages["Warning", 0])
     assert_equal(c.messages["Warning", 0][0], 'debug/: Unknown file.')
@@ -701,10 +709,10 @@ def test_insert_files_in_dir_regex():
                 "InsertFilesInDir": "-e test " +
                 path_on_server})
         assert c.messages["Warning", 2] is not None
-        assert c.messages["Warning", 2][0] == "Explicitly excluded directory or file: {}".format(path_on_server[:-1])
+        assert c.messages["Warning", 2][0] == "Explicitly excluded directory or file: {}".format(
+            path_on_server[:-1])
         assert len(c) == 0
 
-
     finally:
         try:
             c.delete()
@@ -716,7 +724,6 @@ def test_insert_files_in_dir_regex():
             pass
 
 
-
 @with_setup(setup, teardown)
 def test_thumbnails():
     file_ = models.File(name="TestFile",