Small fixes and add a test case.