Improves test coverage

- [x] don't merge until it's done, will add more tests
- [x] @ewinslow @brettp confirm that [AMD changes](https://github.com/Srokap/Elgg/commit/6250fd76ca72bc196788da2a4f83f562f99a5d42) are correct