String: refactored functions and unittests.

* Made opEquals() into a template, so that S("a") == "a" works.
* Improved times(), partition() and rpartition().