Fixed a couple of errors in to_json in count_matrix classes. Added a JSON.parse test case for this