Clean up docs and refactor tests