fix negative counts, add tests