WIP

1. Add more tests
2. Fix warnings
Fix transport termination.
Correct cleanup
Add tests, cleanup code, fix connection.