Added tests. Fixes #2