Fixed remote frame context handling.

Added unit-tests to cover this scenario.
Fixed a bug in _remove_embed.