add count(true) option, to use limit on count

[Fixes #2927]
Refactor count