fix selection bug and failing unit tests