Fix deallocated memory accesses in test code.