ITS#9329 Re-fix merge_state

A bit uglier but more straightforward.
3 jobs for master in 32 minutes and 32 seconds (queued for 2 seconds)