Feature/contexts are context managers

Based on #573, for convenience. Closes #558.