Added API tests. Refactored tests into TestCase classes.