Refactor rspec code