Extract test functionality

Fix #101.
This bunch of `if`s is not the prettiest. @dbu Can you live with it, or should we refactor this into constructing the Proxy classes with some kind of `$config` array instead.?