Added tests and a couple stats functions.