table: improve selection
test: add tests for selection