fixed bug when padding required is 0
extracted test to main.c