Anisotropic dark energy: dynamics of the background and perturbations