Added Debug module. CLeaned up error cases.
Added second test.