Added tests and some debugging tools