Fixed erroneous renderings of JSON

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

I think we should include the following in this PR:

* Add a JSON-based test for statistics in statisticis.test
* Include this fix y CHANGES_NEXT_RELEASE