Fix #22 and add some more test cases.