Fix edge cases

- Check for empty strings first.
- Bug in isUpperCasePresent was covered by lower case check.
- More efficient to get last character through back() call, instead of
through index.