Abstract out chain and add test