Rewrite functional tests

This addresses issue #23.