Cleaned up test mode selection logic