added tests / fixed bugs