Add test for cleaning up file handles for corrupted files
Always close files in case of exceptions upon creation.

If the user of the library gets an exception before he
can get the actual object he will be unable to manually
close it. Therefore the library will now close it instead.