Added unit tests for manual reordering.

Also fixed typo: MAX_LINE_LENTH => MAX_LINE_LENGTH