Add unit tests for internal functions in used in the aggregator

I added some tests in aggregator_internal_test.go. I changed to use dependency injection in the "diff" function for creating stateMachine so I can use mock. I don't know if this is reasonable. So I would appreciate it if you give me direction how to change it :) @peterbourgon
Can you do this in each test, and reset it afterwards with defer? Having it in init is scary :o: