Move API class to api.py
Added tests