Added a functional test and included a close() call on files that are opened when the module/test run.