Use original key value when updating models.

This is necessary in case the primary key was changed.

Fixes #2414.
Fix failing tests.
Add additional unit test for #2414.
Fix expectations for mock objects.
Merge pull request #2695 from franzliedke/patch-16

Use original key value when updating models.
Merge branch '4.0'