fixed a bad rounding error in the distance computation and covered the check with a testcase