Add tests and update API docs