merge function and test case