Fixed erroneous renderings of JSON

### Description
'statistics' json response fixed.
Fixes issue #428 and a little more.
Unit tests added for json part.

This probably will cause a conflict when merging PR #427 but I hope that easy to solve.

NTC