Implement avg and count functions of aggregation plugin and test