changed conditional tree structure and improved print flags in test