Refactor common code from openstack tests.