For ENG-6245, fix memory leak in test case