Added error handle for bad JSON in test code