Fixed problem signalled by failing test in lab.core.
Added test case and fixed bug in the select library.