add tests + refactoring
small fix