Reinstated a test case.
Fixed a bunch more potential thread-safety issues. Still an occasional error getting EOF propagated through the filter chain, however.