Fix smoketest infinite loop. Added script to check if application is leaking memory