Judges rule government’s legal aid plans 'unlawful' and 'discriminatory'