Created Document API tests fixing some bugs and documenting the API