Bummer of a problem. Don't let them take you to arbitration, as it's in their favor. In California you're protected very well against shops that do work they were not authorized to do. They're in BIG doo doo trouble if you can prove (note the bold) you authorized them to install engine x, but they rebuilt engine y instead. They'll likely be ordered to pay any other shop to slap in the engine you originally requested. They'll also likely be ordered to pay for any repairs due to their negligence (your transmission). But - you have to prove it. That usually means taking it to another shop, and having them take a look at what's wrong... and they'll have to be willing to testify if they believe the other shop screwed up.
Things to keep in mind about "Japanese import" engines (commonly called JDM).
1) They're technically illegal in California. But, most smog shops don't check the engine block # - so this isn't really an issue. Unless you're super paranoid.
2) The 40k thing is a total crock of crapola. They can't, and WON'T verify the millage on any JDM engine. The story most people tell:
"Japan has strict SMOG, so they have to retire their cars after x0,000 miles."
LIES! I dare you to find this Japanese law.
What really happens:
Japan is on an island in the middle of an ocean. It's also a VERY small island - where 80% of the population lives in only one harbor city. Like all coastal vehicles, they get eaten up by salt. Japan has vehicle inspections, and if a vehicle is getting too eaten up (especially in regards to the frame), it's retired. Since most the population lives in one city, and the island is super small, the OVERWHELMING majority of cars there see very few miles before being retired. So, they have a surplus of engines with (compared to America) low miles. BUT THERE IS NO GUARANTEE HOW MANY MILES ARE ON AN ENGINE BEFORE BEING RETIRED.
That said, I've known a lot of people happily running JDM engines for many years - even here in SMOG Nazzi country.