updated code and UT to allow for closing of streams after parsing is
done.