Fixed looping over list instead of map; added tests
Merge pull request #4 from papadopa/master

TH