Merge pull request #4 from mbrio/master

Add tests and fix bugs