Fix bug when window offset changed. Expand unit test.