Adding context managers as per #10

TODO:

  * Update docs
  * Add tests for newfunctionality