fix newline escaping in heredocs

Add test case for escape sequences