move visa string parsing into own function

This enables us to test this function.