Fixes #7. Also create test function added