Bug 830943 part 2 - Add asserts, testcase. r=dvander