Add unit tests.

* Fix a few bugs discovered while adding unit tests
* Add unbind method to history.js to simplify unit tests writing
Add js dir to ignored