Updated tests, re-organized API a bit.