factored out test code into demo file, defined module exports