Also ensure NaN are treated properly; add test cases