switched to literate programming and added tests