Ported first batch of selector tests. Fixed lots of bugs in the port. Still more to go...