Add API + tests for Swarm

`except (OSError, 2):` is not correct. What are you trying to do here? It should be only `except OSError:`