NuCivic/nucivic-internal#108 Refactor to reuse duplicated common functions