FLOE-195: Reduce the database save calls as well as adding some unit tests.