I'm quite lucky in that the bikes I sell (recumbents and other oddities) are rare enough that the're not sold cheap online and they only usually come in one size, so stocking a demo bike is easier - and they don't launch new models every year, so a demo bike lasts until it gets scrappy, when I can sell it for at least cost price.
It's still a lot of money to have sitting around doing nothing, though, and deciding which bikes I'll sell enough of to afford a demo bike is a big decision.
You do get a feel for who is a serious buyer and who is just messing about - and, oddly, it's usually the people who want long weekend / multi-day test rides who are least likely to buy I've found. Though, saying that, my current record is 12 years to sell a bike
I've also lost a couple of bikes to thieves - it's just a risk you have to factor in.