Add linear time algorithms to add count & end to a range. Added unit tests and refactored old ones