Various fixes for Rails 4

This will make the rspec pass when running with Rails 4.