Removed an unnecessary optimization and fixed some wacky connection shutdown behavior. Added a test to cover the potentially-bogus shutdown behavior.