Allow context callbacks to perform custom buffer verification and custom element setup. Also move some static tracking variables into helper struct and expose the latter struct for use by unit test (callbacks).
... and tweak parser test helper in the process.