added tests, cleanup