updated the code to make count an option and adapted the tests