Fixed memory leak in test