Final refactoring of tests and docs