fix merge trajectories and tests