Added counter and tests