fix otest-shim crash that can happen with multiple threads

This fixes the crashes found by @bgertzfield.  If tests end up spawning
threads that write to stdout or stderr, some bad things could possibly
happen...

1) the emitted JSON could get corrupted since there was no locking or
serialization there.

2) 'test-output' events could get written outside of the 'begin-test' &
'end-test' boundaries.

Let's setup a GCD queue to serialize all of our events.  We'll always
use dispatch_sync so we can be sure the event gets written.
(dispatch_async would work fine in the positive case, but if the tests
caused a crash, we could lose whatever blocks were in the queue)

Test Plan:
Made some tests that spawned ridiculous numbers of threads that
constantly wrote to stdout.  Observed that I could repro the crash
consistently before I applied this change, and then observed it went
away afterwards.