I understand B's plight, but how hidden was that $500 chip? if it's just lying on the felt behind the other chips then while A should have had it out front I would still rule this an all-in by B. A player should never declare "all-in" unless they are truly prepared to put all their chips at risk and I want to severely limit opportunities to weasel out of an all-in. While A should have had the chip out front, B should also be watching the table, tracking stacks, craning his neck occasionally, asking to re-arrange an unclear stack, etc, i.e. B has some responsibility. Goes for both cash and tourney. If the 500 was jammed into the felt rail or hidden under a drink holder that's another story... (see c).
In item c my answer probably would be different, depending on how well "hidden" the chip was. I lost that argument at Summit 2013, that the hidden chip should be taken out of circulation in egregious tournament situations. Let's say B's total all-in was 125. What sense does it make to give him a 500 chip windfall in a tournament if he wins because the chip was hidden? In a cash game my Rule 1 ruling is the same: would I have made B pay off the very hidden chip? If I wouldn't, then I wouldn't award it to him either.