Fixed null-check
Improved evaluation of formatting options and added tests