Make surrogate work as context manager

This was in the planned features list, and I wanted to use this module in some of my tests, so I went ahead and implemented it myself. There's also a test.