Fix bug #1333098. Concurrent access to the objectCache needs to be protected.

We add a Mutex around the objectCache map.

While there, I discovered a difference race condition in the api Watcher code.
So I fixed that in passing.

The new test fails if you run under '-race', and the tests in cmd/jujud/*TestMachineAgentRsyslog* used
to fail with the race detector and now pass.
(I'd comment on line 156 if github allowed it)

A less intrusive change that accomplishes the same end would
be to wait for w.in to be closed when w.tomb.Dying is detected
in the loop below. i.e. we already have a way of knowing
when commonLoop finishes - why not use it?