Looks like that this completes all outstanding items with the MERGE code.
A slightly improved version attached. Apart from doc cleanup based on earlier feedback, fixed one assertion failure based on Rahila's report. This was happening when target relation is referenced in the source subquery. Fixed that and added a test case to test that situation.