I don't think you have an ethical or legal problem accepting with B. My father was recently in a similar situation and although he had verbally accepted a position with A, he actively pursued B,C and D. And he works in the realm of benefits and human resources. Much of what he said was very similar to what Peale and PCTech have said. As he pointed out, until that contract arrives, all bets are off.
Now, having said that, my own take on things might be a little different.
When deciding what is best for you, you need to consider how choosing B over A might affect you. TMK, A has no legal claim to you, but they WILL remember what happens (all notions of "it's only business" aside, to the person who wanted to hire you, it will be somewhat personal). If you are working in a small industry where everybody knows everybody, as I do, then you may well have to deal with some fallout in the future. This will depend on many factors, including the nature of the industry (if, indeed, you plan to stay in the industry), the amount of effort they put into finding you, etc. It may not be a big deal at all or it may be something to consider if you are looking at two evenly-matched positions.
If the offer from B is better (or if the position is just more attractive to you), then you should certainly explain to A why it is better and give them an opportunity to respond. I would do this in person, if at all possible. Treat them with respect (after all, they have invested at least some time, money and interest in you) and they're more likely to be sympathetic to your situation, which will go a long way to keeping bridges intact.
Oh ... should you eventually choose B over A, be sure to write a letter to A expressing your appreciation for their offer and understanding (even if they aren't very understanding) ... it will go in the file and may help you out in future dealings with A.
Good luck!
Cheers.