fixes #51 with tests!