Add memory leak check target and fix tests