Fix to upgrade script as it was failing in tests.