String conversion function, and tests