TAB on empty line causes crash; with test

If you start `ipython console` and then press TAB, crash! This fixes the issue, and provides a test.