Fixed memory leak in unit test