Fix a memory leak in file opening
Add some test apps that helped track it down