Added test and improved check