Fixed unit test so it now properly closes it's resources.