added a test, and added some helper functions