fixed a dumb bug, added tests