Finish conversion to ostream (as opposed to ofstream) and hopefully fix the unit tests.