some tests, new doc details, refactoring