Fix bug where backspacing to an empty string and using the arrow keys would fail. Added test to prevent in future