Added better documentation and initial tests