agent: fix reg of dynamically allocated ports

Also make job service registration test that this works.
Not for this PR, but when doing my attempt, I kept having to trace what each of the Strings was.  That is: Map<String, String> doesn't tell me what I need to know. Going forward, we shouldn't use Strings for things like this.  But then again, maybe I've been reading too much on Haskell...