AE method testing part I.

First refactoring the stuff around, then writing the tests.