Fixes, refactor for string switch functions, testing.

R=benwells@chromium.org

Review URL: https://codereview.appspot.com/52610043