Fixed all mem leaks for testcase