CBQE-0: fix avg and sum fns

Change-Id: I61930aa1c29cb863eb7c8a55ad5a2cb1fceb778e
Reviewed-on: http://review.couchbase.org/29895
Reviewed-by: Ketaki Gangal <ketakigangal@gmail.com>
Tested-by: Iryna Mironava <irynamironava@yandex.ru>