Remove code duplication in spec