Fix afterDestroy hook

The afterDestroy hook eb8bfc58d396b16a9ce815c60bc84ad1b68c9e83 tries to pass the entity, but it's out of scope. We can conditionally load the entity if either the delete or afterDelete hook will be call.

Also adds tests for the afterDestroy and afterSave hooks.