added QUnit unit tests, moved javascript code to separate files