improve agent test coverage

- add test helper script
- refactor agent tests

Signed-off-by: Johannes Petzold <jpetzold@pivotallabs.com>
improve error handling

- also add tests for error cases

Signed-off-by: Johannes Petzold <jpetzold@pivotallabs.com>