Inference bug fixes by KMahoney

The implementation currently has a bug where substations are not composed in the correct order.
KMahoney fixed this bug which was present in two locations and added a test case which fails due to one of them. I added another test case for the second location where the bug was present.
Cheers! Yair