Added max version tests and impl
Refactored to remove duplicate code.