Added dubgging functionality
added new tests