Assert the token's block is not nil and check it before execution

Further enhancement on #804.
It is nonsense to register a token to realm without block.