fix memory leak in unit test