fix unit test memory leaks