added NaN test for distance
added NaN test for squared_distance