fixes to make unit tests pass
refactored some code used for the compression option