fix a bug in aggregate_item, add test