fixing selection and a logic error in the corresponding test
4.0.4