convert Spy.on_const to a non recurrsive function