Improve testing and rewrite of json_errors
Split out local and recursive bit of json_errors