Code refactoring to improve test coverage (II)