Improve test_upgrades

Avoid duplicating code