Fix invalid substring range parameters

Fix the fix in decodeEncodedWords to do proper checking of -1 return
values from String.indexOf, and make similar fixes in decodeEncodedWord.
Add unit tests.

Bug:15016488
Change-Id: I607c363bd2dcf76a95d233644e00de74b69770d2
2 files changed