Switched code from using hasAttr followed by getAttr to simply call getAttr directly and check the resulting value. Also fixes some minor formatting issues surrounding the getAttr code.

No functional changes intended.