Macros review and tests added

- Refactoring of process_macros_r() function
- Extra tests added to validate invalid macros and escaped $ sign