added tests, bugfix