move test file into new api subdirectory
duck-type `origin` property and drop `instanceof`; cleanup
formatting