So as Kehel18 put it the problem was in the same parameter names from material functions that were exposed to the final material.
I can be solved by creating separate functions for each layer without parameters or using separate parameters for each layer in final material instance.