this function belongs in testing/misc_tools.c