Fix bug with COUNT aggregations

The reduce function for count was not idempotent