Removed the inconsistencies of count method (Issues #3368 and #4228)
Improve the test for checking the consistency of count method