Fixing some memory leaks on the tests