cleanup
 
Simplified validation logic.
Added a new test case to test wrapping.
Added more test cases.  Corrected problem for string of length 1.