Updated with more tests and improved maintainability + readability 

^ Resolved