Fixed some js errors
Created a test case