Add memory test script to detect leaks