added spy/stub tests, and some fixes.