make code more testable and test it