fixed some bugs, added test.html
moved the script to head