Unwrap if needed for the reference node in insertBefore

Also, unwrap if needed for old child in replaceChild.

Fixes #319