Add a test and fix a length bug.