RT3856: Fix memory leaks in test code