We consider the 3D instability of a layer of horizontal magnetic field in a polytropic atmosphere where, contrary to previous studies, the field lines in the initial state are not unidirectional. We show that if the twist is initially concentrated inside the unstable layer, the modifications of the instability reported by several authors are only observed when the calculation is restricted to two dimensions. In three dimensions, the usual interchange instability occurs in the direction fixed by the field lines at the interface between the layer and the field-free region. We therefore introduce a new configuration: the instability now develops in a weakly magnetized atmosphere where the direction of the field can vary with respect to the direction of the strong unstable field below, the twist being now concentrated at the upper interface. Both linear stability analysis and non-linear direct numerical simulations are used to study this configuration. We show that from the small-scale interchange instability, large-scale twisted coherent magnetic structures are spontaneously formed, with possible implications to the formation of active regions from a deep-seated solar magnetic field.