Fixed infinite loop and added ascii tests.