add tests
refactor && error fix