Optimization of quantum universal detectors