Issue #1 - unittest for gateways.py and minor changes