added JavaDoc to reverse and fixed reverse bug
added reverse tests