refactor
Add tests
update doc