It could be a good deal - or it might have a cracked head/etc and you'll wind up dumping another $3+ grand into it plus your time.
I agree with the others; the deal should rest on whether the engine has decent/even compression.
At that milage, you'll have to see if it's up to date with its maintenance: no cracks on coolant tank, suspension works, wheel bearings, standard stuff for an older car. You'll end up dumping even more money into it if these aren't good.
Seems like you know what you're getting into with a S40. Give it a good look, and get the story as to why it is so cheap. Check the frame / VIN report, engine, etc pretty carefully and let us know how it goes!
What's wrong with it???? That would be my first question. If it is mechanical, I know you can figure out how to fix it, if its some weird electrical gremlins or water damage, RUN! It could be as simple as a cam position sensor or fuel pressure sensor though!