Issue #18634 - Unload the constant before calling Formula.factory

This seems to fix the problem.  Instead of unloading the constant after calling Formula.factory do it right before.