Fix #13 and add test
Merge pull request #14 from automata/master

Fix #13 and add test