Removed test function and made the script able to be used as an external module.