Improve nonce check
Improve testing framework