added tests
added comments for clarity