Remove repeated test code
Handle failures in temporary_install better