glib2 test: extract common code