refactored count_cart method and got test to pass