reduce duplicate code
rename method
add a few tests
Travis CI