Fixes #6 with tests