Fixed intermittent crash when loading test_json.so

The JSON test attempted an overly clever use of RAII_VAR to run code
at the beginning and end of each test, in order to validate that no
JSON objects were leaked during the test.

The problem is that the validation code would run during the initial
load, when the tests were initialized. This happens during startup,
when other parts of the system might actively be allocating and
freeing JSON objects.

This patch changes the RAII_VAR to use the new
ast_test_register_{init,cleanup} functions to run the validations
properly.

(closes issue ASTERISK-21978)
Review: https://reviewboard.asterisk.org/r/2669/


git-svn-id: http://svn.asterisk.org/svn/asterisk/trunk@394203 f38db490-d61c-443f-a65b-d21fe96a405b