fix argument parsing, add function tests and a more comprehensive module test