Added formatting test and fixed bug in formatting