Added in unit test for NioConnection
Fixed several possible bugs based on find bugs
Did some code formatting