Separate topology handling in selection tests.

Split common functionality for handling test topologies in selection
unit tests into a separate files (toputils.*).  This commit does not yet
add a lot of reusable code, but subsequent commits will (and they will
also introduce more files that use this functionality).

Part of #651.

Change-Id: Idda0099ba166014c9d6c36e0d8ba212e5fa8e940