[PATCH 3/3] tests: Properly open/close the file