refactored and more tests added
rubocop on spec directory