Switched test cases to use g_test_trap_subprocess on glib >= 2.38

Added compatibility with glib 2.38 which deprecated the usage of g_test_trap_fork. It has been replaced with g_test_trap_subprocess and g_test_subprocess. The change uses the GLIB_VERSION macro to only make the change on glib 2.38 and up.