Add closure test for memory leaks