refactor and add tests to narrow down rotation confusion, still not fixed