add periodic wrap function
be a bit more forgiving in tests