Add tests and fix some issues, prepare for initial release.