Add union tracking operation

Also includes some cleanup of the testing framework. @tdumitrescu and @ttrefren please take a look!