Fixed bugs with line wrapping, extended tests (refs #1)