Refactor the conditional casstring code to incoporate the conditional functions into the main class.
Further unit tests.