more bug fixes, extended tests