Written some tests and refactored the server api's document endpoint