Further improve test to avoid square roots.