fix memleak in testcases