Fix firefox tests

ref #34

This PR fixes all the unit tests on Firefox, it includes the backward selection fixes for firefox. As of this PR, all the existing tests are passed on Firefox(I'm on nightly channel, so it may be possible that stable version differs).

And since I only run the unit tests here, it might be useful to also test the code in a demo environment.