Testing and realization of threshold functions by the canonical composition structure