Refactored some entity CRUD stuff.  Added some more tests.