trim whitespace
modifications to code for better testing
Update tests