Fixed some bugs

also sort of set up some unit testing
though I have to find a way to internally unit test inside the jquery
plugin