Back in 2007, Immigration and Customs Enforcement began teaching Maricopa County Sheriff's deputies to enforce some immigration laws. It was a program known as the 287(g) task force program, which deputized local law enforcement officers to carry out some immigration enforcement duties.

Yet the training apparently included a mistake.

The training manual suggested law enforcement can consider a suspect's Mexican heritage, as long as it is not the only factor, when determining if there is a reasonable suspicion someone is in the country illegally in order to investigate immigration status.

But the Ninth Circuit Court of Appeals has already ruled that's not legal.

"The Ninth Circuit had made it fairly clear that in states like Arizona, with high Latino populations, Mexican appearance should not be considered as an indication of any kind of immigration status," said Kevin Johnson, the dean of UC Davis Law School.

The Department of Homeland Security would not comment on the ICE's 287(g) training, because the case is still in court.

But DHS did say in a statement that it "has no tolerance for racial discrimination and will not be a party to such practices."

Johnson says it is surprising the feds got the law wrong.

"There is really no excuse, given the amount of resources that are being focused on border enforcement why the ICE training couldn't be effective, why it couldn't be accurate, why it couldn't be truthful to the law," Johnson said. "It's really inexcusable."

ICE did not renew its 287(g) task force agreement with Maricopa County Sheriff's Office in 2009. The 2013 ICE budget makes clear the agency is phasing out the 287(g) task force program, and is suspending requests for new task forces.

Meanwhile, lawyers for Sheriff Joe Arpaio have shifted the blame back onto ICE for its allegedly flawed training program.

"It certainly is troubling that ICE was training 287(g) officers in Maricopa County to use ethnicity as one factor in making law enforcement decisions," said Tom Liddy an attorney with the Maricopa County Attorney's Office who is part of Arpaio's legal team.

Liddy said that was not the policy of the MCSO.

"The main point is that it must be stopped, and the hundred deputies trained by ICE must be retrained," Liddy said.

During the trial, multiple deputies testified they believed they could consider race or ethnicity as one of many factors when making immigration law enforcement decisions.

"As an American citizen, I would want our President of the United States and I would want our Director of Homeland Security to take immediate steps to ensure that race and ethnicity is never used in a law enforcement decision," Liddy said.

But in last week's ruling, U.S. District Judge Murray Snow suggested MCSO still deserves plenty of blame for misinterpreting the law.

According to the ruling, after ICE's 287(g) task force agreement with MCSO ended in 2009, MCSO Sgt. Brett Palmer incorrectly told deputies that immigrants in the country illegally were committing a crime, and could be detained solely for that reason.

Deputies had a practice of then turning over those immigrants who could not be arrested on state charges to ICE.

On Wednesday, Arpaio said in a video message on YouTube that his deputies will "no longer detain persons believed to be in the country without authorization who we cannot arrest on state charges," as required by Snow's ruling.

A hearing is scheduled for June 14 when Snow will decide how his ruling will be implemented.