factory: add docstring and fix imports for set_connect_env()