finish up market api and tests