Corrections for xml handling and session save

See comment https://github.com/sbt/sbt/commit/e8218faa7fb777ab99e7615fa0fecd1e6580264b#commitcomment-7954217

Still can be problem with white spaces in tests.
I received:
```
Caused by: java.lang.RuntimeException: Test script error: File contents are different:
k1 := {error("k1")}

k2 <<= k1 map identity
And:
k1 := {error("k1")}

k2 <<= k1 map identity

	at scala.sys.package$.error(package.scala:27)
```
But I have no idea - what is wrong? End of line?