Actually fixes #563 with tests