added testcases for ngrams loading
minor refactoring and small tests improvements