fixed some db issues

- fixed udate db primitive
- refactored agent utils
- implemented unit tests for agentutils