Write tests and doc