Pdi 7811

What was done:
1) slight refactoring of the code that allows unit tests to be added
2) unit tests added
3) filename processing changed a little bit taking protocol into account