Trims whitespace and adds tests