Repackaged some stuff that didn't get handled earlier, added some poc unit tests, and added ability to upsert db object