Refactors object properties iteration

There was some duplication on iterating function's prototype properties stubbing and object properties stubbing.

Tests are the same, just tried to improve code's readabilty :)