Fix bugs around ref and CT-boundaries argument

Improve test for issue 9654 and 3652.