add tests and protect counter ops with mutex

* test coverage at 80%
* race detector is happier