Added test and code to fix problem with nan n-gram being interpreted as NaN.