fixing done callback, fixing agent setting and adding tests. fixes #4, #2, #3.