Refactor is_binary_string() to use same code for Python 2 & 3.