Added support for spying function with prototype