fix file close on test end