Fix memory leak for test driver