Fixed bug with merging JSON stats and added test for it