counter function replaced by inc and dec.
Tests updated.