Use cargo
Fix bug and add test