Added context manager tests to api and session.