small refactoring
add tests
add tests for fail method