added array & obj support to attrs.js (plus refactor)

This PR contains some refactoring changes to attrs.js, as well as the addition of array and object support, as per our discussion on #126.

The tests pass, and I added some more, but please let me know if I forgot an important detail or two that we discussed.