fix memory leak in test