more tests; more helpful error messages; fixed bug related to garbage collection and file IO by adding 'temp_file.close' line