fixed up the API and added some testing