fix serious flaw in testing logic