Refactor to use custom exception types
Add tests for AST checker
Add test for format_path