rspec tests with refactoring