Gauge invariance of systems with first-class constraints