add sanity https support and refactoring AdvancedAgent
fix tests for https
Merge pull request #82 from nodules/https

Add some support for https