Fix test suite for Rails 3.2.19.
Fix a problem with exception checking.
Split up in separate source files.