Fix a bug, and adding tests
Merge pull request #16 from bguerin/master

Fix a bug, and adding tests