The code you pointed out is just to check if it is using the testing server or not. If its using the testing server then the code is implemented.
One thing you might not want to do is to show the shipping in the cart page. This is because you don't choose the shipping provider until after the cart page, so it won't be an accurate display of the shipping cost.
For the headers already sent errors, this is usually caused by if you have extra white space between the closing php tag and the opening php tag of the next php block like this:
?>
<?php
You want it to look like this:
?>
<?php