Fix sum stats

Add tests

Change-Id: I33b905c250eef000fe88648bb65eee726f4e5395