Botfair, it does not see them as settled because of the switch from test mode to live, as the criteria for determining if a market is settled are different in test and live mode.
mcbee, I'm afraid this workaround will not help as it returns the index of the previous winner, not the index of the winner of the previous market. So if, for example, there are three races and the first one is settled, and the second one is not, then in the third market pw_1_sel_index will still be equal to the index of the first race's winner.
I'll need to give it a further thought and to come up with a working example. Will update you on this later.