More selection unit tests for variables and fixes.
- Added unit tests for more complex selections where either numeric or
position values were assigned to variables.
- Fixed handling of subexpressions in these cases (will back-port to
older branches separately).
- Added unit tests for constant expressions in variables (in particular
constant positions were not handled right during initial development
of selections).
- Added comments in the code for some parts that are currently
unreachable.
Part of #651.
Change-Id: Ifbb585ca00fd7a9715b4c9cb004c3a895551c1a6