Maintain consistency of internal changed attributes hash.

This makes sure that the `_attributes` hash used to determine current
attribute values (and dirty state) is always in sync with the record's
original values.
Merge pull request #1716 from slindberg/attributes-consistency

Maintain consistency of internal changed attributes hash.