test: add rotate.go and fixedbugs/bug313

Update issue 4139.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/7094047