refactored api, add shitload of tests (some still failing)