added tests, refined unit test framework