Minor fixes: include header, test type cast and return correct value