fix file leaks in unit tests