Home Office acted unlawfully in implementation of EU settlement scheme, court told