test: Use SafeWriter to avoid races

Signed-off-by: Jonathan Rudenberg <jonathan@titanous.com>