Completed exception handling in to_json_stat and tests. Checked with pylint. Completed some more documentation