I don't know about your particular case, but the reason they had to keep my car for days is because of weather. After sensor replacements they had to verify the issue is resolved or it's pointless to just keep replacing the sensor and hope for the best. The main cause of this issue has to do with weather and if the temperature doesn't hit certain degree or the sun doesn't shine at the door or at certain angle they were not able to reproduce the issue. However once the heat was consistent the issue was easily reproducible. They just had to wait for that day.
2 separate transactions. They buy your car back and you order a new/inventory car from the website or whatever. Or you don't have to get another Tesla. They just pay off the loan if any and cut you a check for the difference of the agreed re-purchase price, which is composed of the price you paid minus fed credit minus standard mileage usage deduction (based on 1st recorded mileage of the issue first appeared). You can also negotiate for something between these 2 transactions. For example, I requested they let me keep the old car until the new one arrives and it was approved. I've heard another member requested extended warranty on the new purchase and they approved it.