Various improvements and fixes

Added test_and_set_status method so entities cannot be modified while in a
transitive state.
Implemented delete methods that were not implemented.
Various error checks.

Change-Id: I517493fb86b3202deaa2119bb4e0d2c9f5636fa6