fix missing deallocation of memory in the test cases for c-interface