Refactor

tests and docs