Fix length check; update tests