restructured api. updated tests, docs