Unit tests

* Make get__Targets methods protected and change tests to match
* Fix bugs found while writing tests
* Correct assertion order in existing tests and other minor changes

Note that some new tests perform equality assertions on entire arrays,
which is fragile (dependent on how elemenets are ordered). Not sure if
this is bad (the order remains consistent in practice, but order
shouldn't matter).

Change-Id: I75f132f4ea6c411cacd0e1813311d75655ceb7ae