Added some unit tests, consensus fixes