tests: Factor out a helper function
tests: Factor out a helper function

This introduces no functional changes, but will allow that code to be
reused in the following commit.

Signed-off-by: Philip Withnall <29c2a2ac2a854b9cf047275aa9de346d096be2e0@endlessm.com>

frida/json-glib,frida/json-glib,GNOME/json-glib,GNOME/json-glib