write tests and docs