Closes #21 and fixes tests