Fixes #3 with tests