fix memleak in testcase