Restore sample selection to tview and add a unit test for the code doing it.