Adding JavaScript test class

adding JavaScript test class and fixed a few bugs in my code