Bugfix: only remove actualy failed blocks from setBlockIndexValid

Fix an unexposed bug in dealing with invalid blocks: only chains with actually invalid blocks should be removed from the set of potentially new tips.

Also, in case an error is found, the failed block itself must be removed from that set.

This would be exposed by #4468.