Refinments to bug848 commit to fix tests that were failing. Clean up the profile selectors to make the implementation easier to follow. Fix the codeset test to work on a mac.