Fix magn3087

This submission is to fix defect MAGN-3087: [crash] on creating CBN.

The defect is because of an error in calculating the position of output port. This submission re-factored the calculation logic, re-implemented it in SetOutputPorts().

The submission removed CodeBlockUtils.GetStatementFromOutputPortIndex() and its related test cases because this method is not used in the code.