Fix a bug, and adding tests