Fixed memory leaks in test program.