Improved test phase handling.