Added most of testing functionality. Pending testing.