Unexpected results when using MEP Pipe.ByConnectorEndpoint

I’m trying to create a hydronic supply and return pipe from a VAV box and place valves on them.

I’ve tried using the MEPFitting.ByPointsAndCurve, which placed the valves in the correct orientation and location on the pipes, but didn’t connect them to the pipes.

So, I decided to use Pipe.ByConnectorEndpoint node to create pipes from the valves and eventually connect them. I placed the valves in the model manually, and selected them to get their connectors. I then plugged each connector into the node with a distinct point on the line.

However, I do not get consistent results when I run the script. Sometimes, the valves move to an endpoint, draw both pipes from the same end or not create pipes altogether. I have tried this with all the combinations of connectors, in case I was trying to create a pipe from a point to a connector on the opposite side of the valve. I have also restarted dynamo and ran the script several times, but I still get different results.

What can be the reason behind this? Is there a better way to create valves on pipes and connect the pipes to a VAV box?

Images of the results are below