Made BuildXAxis more robust and wrote tests