autosave_association issue that occurs when table has unique index

Per the comments in pull #3329, 
If you have a table with a unique field index, and you mark a record for destruction, and you build a new record with the same value as the unique field, then when you call `save`, a database level unique index error will be thrown. 

This happens because the record destruction happens after record creation.

In this pull request, I moved the record destruction ahead of the record creation.

This is my first pull request ever, so please go easy on me.  :smile: 

The existing tests still pass.

Is there a way to write a test that takes into account a table index?