test/core: Replace overly verbose test code with spies