One more fix should have been in last: was generating wrong var name
Fix memory leaks in test code