refactored tests and cleaned with rubocop