refactored compression class and added JUnit tests