Asynchronous function spying for testing.