index: implement multi-block selection logic for execute()

With a test case included as well.