added tests, fixed doc, fixed bugs