Fix resolve_morphism to build well-scoped terms in case some arguments
of the function are dependent.