fixed ngram library and added test for it