Refactor MenuFromLines (+ some testing)

Change-Id: I46b2ed6eafaf7fffd1867799b49dc577245b2f78