Added attribute tests

Refectored some parts of the code that were checking to see if an
attribute exists. More instances can be replaced using this method