Fix wrong rollback code (off-by-one)
Add test for previous rollback case