Add tests for IDCounter.
Fix redundant YAML read.
Make more robust lock.