Three men took the government to court over what they described as “prison-like” conditions.