Added creation of output stream

Change-Id: I6f4cca68cdca4abdc1729027fa5a706ed2fb2965
Fixed some assertions in Agent Test

Change-Id: I7b8c3dc87d11161d9ffb84afbb79c5aa47c41812