Add tests
fix some jslint issues