Extract test functionality

Fix #101.