Fixed spy and added test for it.