Fix serialization when store_key option used
Handle nil value
Only mark an attribute as dirty if it actually changes

Every time an attribute was being set, it was being marked as dirty,
regardless of whether it was actually changed or not.

This meant, for instance, if you had an edit form, and a user was to
submit that form without changing anything, the attribute would be
marked as dirty.

This brings it in line with ActiveRecord dirty handling, by only marking
an attribute as dirty if it actually changes.