Lock counter



<!---
@huboard:{"order":115.0,"milestone_order":53.0,"custom_state":""}
-->

This function looks ok to me but sees like a candidate for a good unit test.