Add code and tests for `spy_on`