bug fixes & tests