A group of judges and firefighters have won a court case against the government, as changes made to their pension schemes have been considered discriminatory.