Round out variable determination and add tests