add docs, test cases, and minor refactor