Fix test run
Add unlocking before file closing