Add test cases for docs. Refactor test cases a bit.