Fixed spill memory stream bugs. Added tests to verify spilling.