Added function to trim trailing whitespaces (with tests).