Fix tests to handle NaNs