start api testing
Fix attributable bugs, get first api test passing
Refactoring