fix for memory leaks in tests