Fix bad unit test with undefined offset (spotted by @stloyd)
Fix bug where backspacing to an empty string and using the arrow keys would fail. Added test to prevent in future