fixed more bugs; added test.js