refactor and removed deprecation warns on rspec