Fix algorithm to produce less phi vars and strengthen tests by requiring that native mode compilation succeeds