Fixing a bug, adding more tests