SERVER-6062 clean up of str::stripTrailing. added unit test.

Closes #795

Signed-off-by: Benety Goh <benety@mongodb.com>