Refactor to aid re-use

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1557080 13f79535-47bb-0310-9956-ffa450edef68
Add tests for setting null and duplicate read and write listeners for
non-blocking IO.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1557081 13f79535-47bb-0310-9956-ffa450edef68
Fix failures in newly added tests

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1557082 13f79535-47bb-0310-9956-ffa450edef68