Fixed api call error, and included tests