Adds more API tests; refactors into a module.