You should be writing some sort of sales contract with any seller for a used bike. Just a hand wirtten thing that you each get a copy of (and both sign) detailing the bike (VIN, mileage, etc), price, and conditions of sale (as is, safetied, etc).
One of the conditions of sale you can ask for is that the bike pass inspection with a garage of your choice.
If you or the seller have a pick-up or trailer (or you have a friend with), you can get it there yourself, usually with a small down payment to the seller. If it fails in the inspection, you get the down-payment back, and the seller has an inspection report he can use to fix the bike, or show other potential buyers just what is needed.
I did this on one bike I almost bought. The bike looked pretty fair, but as soon as the mechanic got to it he said it would take $2k just to pass safety, and even then it would have a short life (too many parts worn). I tried to use this to negotiate a lower price, but the seller was firm. In the end I walked away from it. And I’m certain that was the right choice.