add whitelist mode + fixes and tests