Prd 4691 nested function

Fixed unbalanced parenthesis in main formula when user enters a inner formula as a formula parameter.  Added corresponding test-cases.