Extracted append_pin and added test