added tests, fix