trim newlines from empty lines
extend test case to show the return bug
Base remove useless changes between taf2 branch