refactor dlfcn test code