added pre- and post-test loops