Trimming utilities for containers and strings, and tests