Fixed test cases and trimmed down code size

Please review the changes and help me add some more test cases for up, down and shift tab.

Once it's done, I'll merge and we can think about how to extract all these semi-hardcoded keybindings out to an extension so the keybindings are configurable.

Also, please following my Google's coding style and use 2 spaces for tabs next time.