The dynamics of stars around spiral arms