Fix memory leak in test program