Added test to count API, implemented changes suggested by review.

Closes #3898