Removed code duplication in unit tests