add tests and protect counter ops with mutex

* test coverage at 80%
* race detector is happier
Merge pull request #4 from measure/s-refactor

add tests and protect counter ops with mutex