agent: fix reg of dynamically allocated ports

Also make job service registration test that this works.
Yeah, having typed value objects instead of Strings might've been good. Unfortunate that java doesn't allow e.g. golang style `type Foo String`