big refactor of protocol functions
implemented file protocol; added some code to test file protocol in test dir
refactoring test functions
refactoring test functions