added QUnit tests (not yet for all methods); some code cleanup; first version that can be used in production