Fix deprecation warnings in tests and use rspec expect syntax