refactoring
added stubbing of functions
fixed test suite and emerging bugs
added tests for call substitution