agent: abstract out publisher function

This changes the agent UnitStatePublisher to accept a publish function
instead of always depending on the registry. In combination with the new
pkg.Clock interface, this makes it easier to test the time-dependent
behaviour of the UnitStatePublisher.

pkg.FakeClock is now exported to facilitate testing.