PRD-4565 & PRD-4552: Bunch of formula editor fixes

Fixed getParameterCount() as it was always returning the number of parameter fields without regards to if there is any values in there.  Fixed catch-all logic.  Prevent NPE & ArrayOutOfBoundException.  Added more test cases.