CallbackFunction implementation and tests (plus a few small fixes that I needed to make)