count and count_if algorithms and tests