More comprehensive tests. Fixed bug in root key validation.