Move variable parsing logic to external lib. Implement initial tests