bug fixes + tests