Fixed test memory leaks