rearrange tests to avoid access past end of string

as demonstrated by abi6637-1.doc

Change-Id: Ieed0ca7ccf2d8587179a4530a1da29d7d8228363