Fix test memory leak