Add assertions and death tests for unlocked states

Terminate the program when trying to access stable or
workingCopy buffers when the state is not locked properly.