(Reuters) - A federal judge has ruled that Tesla must defend itself at a trial over allegations it knew foreign workers at its California assembly plant were threatened with deportation if they reported an injury and worked long shifts that violated forced labor laws.

FILE PHOTO: A Tesla showroom is seen in Santa Monica, California, U.S., January 4, 2018. REUTERS/Lucy Nicholson/File Photo

U.S. District Judge Lucy Koh, in San Jose, California, dismissed most of the seven claims against Tesla on Monday, but allowed two claims to survive, paving the way for the plaintiffs to seek documents and witnesses to build their case.

The decision comes as Tesla is under pressure to turn a profit and days after Chief Executive Officer Elon Musk stepped down as chairman to settle allegations by regulators that he misled investors.

Tesla has been plagued with safety complaints brought by workers, allegations that Tesla denies. Workers say that long hours and pressure to deliver vehicles quickly takes a toll, and some have pushed for a union.

Tesla said it investigated the allegations and broke ties with a subcontractor, ISM Vuzem, that it said did not live up to its expectations. “We’ve also since improved our supplier contracts and policies to better stop bad behavior,” it said in a statement.

According to the lawsuit, Gregor Lesnik of Slovenia came to the United States on a B-1 visa and worked 250 hours per month for less than $950, well below minimum wage. It also alleges that foreign workers were threatened with deportation or reduced pay if they reported injuries or became ill.

The 2016 lawsuit by Lesnik and Stjepan Papes of Croatia seeks class action status on behalf of foreigners with B-1 visas working at construction sites at U.S. auto plants.

Tesla was one of several automakers named as defendants, but the only one that was not dismissed from the case because plaintiffs only alleged to have suffered threats of deportation at Tesla’s plant in Fremont, California.

Koh denied a motion to dismiss for two Tesla subcontractors, Eisenmann Corp and ISM Vuzem because they operated at the same plant.

Eisenmann and Vuzem did not immediately respond to requests for comment.

Koh said her ruling was based on a “generous reading of the at times incomprehensible” lawsuit, but also said the allegations against Tesla and Eisenmann were “uncharacteristically specific.”

Koh rejected arguments that Tesla and Eisenmann were not liable because the alleged abuses were committed by Vuzem. Koh said a party that benefits financially from another’s abuses also bears liability.

The claims she dismissed alleged violations of the False Claims Act, Fair Labor Standards Act and the Racketeer Influenced and Corrupt Organizations Act, or RICO.