bit of code cleaning
Merge branch 'qgram'
added tests and some comments, doc