Superconductivity in layered ternary chalcogenides AxTaS2 and AxNbS2 and influence of topotactic solvation