Added testcases, improved JavaDoc.