cleaned up code and wrote unit tests for tags and attributes