refactored of rspec code for better rspec