fixes #2422 Rails 3.2: before_destroy / dependent => :destroy ordering
fixes #2400 clean up tests so there are no orphaned foreign keys
fixes #2400 migration to remove orphaned records and add foreign keys constraints to database tables