First move in isolating logic
gofmt main_test.go
Fix a reported data race
Fix another reported data race (I think)
Fix unittest race
Merge pull request #399 from Joushou/separation2

First move in isolating logic