Fixed global memory leaks for a few tests.