simplify and extend in/not-in and is/is-not optimisation, add test