Adapt to rails 4.0.3 and pass all the tests