It was not illegal work. He had three separate LMIA exempt closed work permits from his time there, and was assessed for eligibility each time. Though I don't fully understand the agreement, it was a very large company contracted by CN (a Canadian company) and backed up by immigration lawyers...