Add regression tests for comparison with NaN
Fix NaN comparison bug