added test function and some other minor updates