Testing gamma-ray bursts as standard candles