Fix an infinite loop while merging tables

While writing docs on broadcasts I ran across a broadcast graph
configuration that caused an infinite loop in merge_tables.
I've made things more robust by better standardizing the data type
that gets passed to _next_merge and added a test case for that
graph configuration.