Dynamics of purely kinetic $k$-essence in presence of a perfect fluid