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