determine character length correctly and fix tests