Ensure that a file is closed in the tests