Fix data races in state/apiserver tests

It seems odd that you would do the writing from the channel into the output directly. I'm a bit surprised that your change actually fixed anything. Is it just that go wasn't guaranteeing the data being written to Write was showing up in the output buffer unless you have some sort of synchronization? I suppose the issue could have been that you were writing to bytes.Buffer in one goroutine and then reading from it in another without actually having a synchronization primative. Would it be better to add that rather than force it to go through a channel send so that the output.Write and the output.String occur in the same goroutine?