Improving branch coverage and fixing bugs