improved detection support and added tests