refactorings

* define macros to mimick wiring for unit testing
* add class FileStream to mimick wiring for unit testing
* extract class ProtocolWrapper from Main