rewrite tests, refactor core.select