Fixed memory leak in unit tests