added unit tests via QUnit! and fixed bugs that were found. and reminimized