More test memory-management fixes