Fixing defect that caused nested environment variable translation to fail beyond 2 levels. Fixing broken tests and ensuring they cover cases.