Tests with the Main API
Huge refactoring