more fixes; in particular, handles mocked functions in tests more correctly