Councils headed for court over welfare cuts